home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!news
- From: rajash@ix.netcom.com(Rajash Gopalakrishnan )
- Newsgroups: comp.lang.c++
- Subject: Floating Point Error Traping by try and catch:-
- Date: 14 Mar 1996 03:18:47 GMT
- Organization: Netcom
- Message-ID: <4i836n$2u8@dfw-ixnews5.ix.netcom.com>
- NNTP-Posting-Host: pal-il3-14.ix.netcom.com
- X-NETCOM-Date: Wed Mar 13 9:18:47 PM CST 1996
-
- Hi Experts!.
-
- We were using normal try and catch statements to trap
- the exceptional errors occured during C++ class operation.
- We are working on Soaris C++ 4.1 with Toolsh++ classes.
-
- Here is a sample program which causes floating point error.
- If anybody have a clue, please tell me a method to trap
- this error.
-
- BOOL Divide_By_Zero();
-
- main()
- {
- try
- {
- Divide_By_Zero()
- }
- catch(long&)
- {
- cout << 'Got Error' << endl;
- }
- }
-
- BOOL Divide_By_Zero()
- {
- long i,j;
-
- i= 4.0;
-
- j = i/0; // causing Floating Point Error
-
- return TRUE;
- }
-
- Here what I found is that before catch, arithemetic experssion fault
- occurs and core is dumping. One method I found is to redirect the
- signal
- handler and do a catch but that's a round about method. Can anybody
- explain how we can handle this situation by try and catch alone. Is
- there
- any method to show where error occured and line#.
-
- Thanks
- Raj
-
-